﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NumberMark
{
    public partial class Form1 : Form
    {
        public static string num;
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            NumberInput ni = new NumberInput();
            ni.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String[] str = num.Replace("\r\n", "@").Replace("\n", "@").Split('@');
            WinNumber[] wnl = new WinNumber[str.Length];
            for (int i = 0; i < str.Length;i++ ) {
                String s = str[i].ToString();
                WinNumber wn = new WinNumber(s);
                if(i>0){
                    wn.setMissCounts(wnl[i-1]);
                }
                wnl[i] = wn;
            }
            //MessageBox.Show(wnl[0].ToString());
            dataGridView1.DataSource = wnl;
            dataGridView1.Show();

            //修改遗漏大于2的单元格背景颜色
            Color BackColor = Color.YellowGreen;
            int KeyTimes = 2;
            for (int i = 0; i < wnl.Length; i++)
            {
                if (KeyTimes < wnl[i]._Num_01._MissCount)
                {
                    dataGridView1.Rows[i].Cells[1].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_02._MissCount)
                {
                    dataGridView1.Rows[i].Cells[2].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_03._MissCount)
                {
                    dataGridView1.Rows[i].Cells[3].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_04._MissCount)
                {
                    dataGridView1.Rows[i].Cells[4].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_05._MissCount)
                {
                    dataGridView1.Rows[i].Cells[5].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_06._MissCount)
                {
                    dataGridView1.Rows[i].Cells[6].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_07._MissCount)
                {
                    dataGridView1.Rows[i].Cells[7].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_08._MissCount)
                {
                    dataGridView1.Rows[i].Cells[8].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_09._MissCount)
                {
                    dataGridView1.Rows[i].Cells[9].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_10._MissCount)
                {
                    dataGridView1.Rows[i].Cells[10].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_11._MissCount)
                {
                    dataGridView1.Rows[i].Cells[11].Style.BackColor = BackColor;
                }
                if (KeyTimes < wnl[i]._Num_12._MissCount)
                {
                    dataGridView1.Rows[i].Cells[12].Style.BackColor = BackColor;
                }

            }
            dataGridView1.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("该功能暂不可用");
        }
    }
}
